package IC.AST.nodes;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import IC.AST.*;

/**
 * the top-level program
 */
public class Program extends ASTNode {
	private List<ClassDecl> 		classes;	// the program class declarations
	private MethodDecl				main;
	private Map<String,String>		stringLiterals;

	/**
	 * @return the stringLiterals
	 */
	public Map<String, String> getStringLiterals() {
		return stringLiterals;
	}

	/**
	 * @return the main
	 */
	public MethodDecl getMain() {
		return main;
	}

	/**
	 * @param main the main to set
	 */
	public void setMain(MethodDecl main) {
		this.main = main;
	}

	/**
	 * @param classes the program class declarations
	 * @param fileName TODO
	 * @param line the node line number
	 * @param column the node column number
	 */
	public Program(List<ClassDecl> classes, String fileName, int line, int column) {
		super(fileName,line, column);
		this.classes = classes;
		this.main = null;
		stringLiterals = new HashMap<String,String>();
	}

	/**
	 * @return the program class declarations
	 */
	public List<ClassDecl> getClasses() {
		return this.classes;
	}

	public void addClassDecl(ClassDecl cd) {
		classes.add(cd);
	}

	public <D,U> U accept(PropogatingVisitor<D,U> v, D context) throws Exception {
		return v.visit(this,context);
	}
}
